home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 914 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: jdmorris@ix.netcom.com (Jason D. Morris)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Suggestion to the C++ standard
  5. Date: 29 Mar 1996 20:06:35 PST
  6. Organization: Netcom
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <315cafc1.4316827@nntp.ix.netcom.com>
  9. References: <4jatnm$s9b@post.tau.ac.il> <31599c95.4890732@nntp.ix.netcom.com> <315c0f6e.956220382@news.datalytics.com>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Sat, 30 Mar 1996 04:06:09 GMT
  12. X-NETCOM-Date: Fri Mar 29  8:05:17 PM PST 1996
  13. X-Newsreader: Forte Agent .99d/32.182
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBVAwUBMVyzTEy4NqrwXLNJAQFuQgH/ZB4NGeEbwgWeuG92yN2G8mbYqCDex0a+
  16.     eDjUQQqemD+kxdAAPqfF1eoxuHwWMLMYkGXMpRNJ0rmmS5s/12S4jw==
  17.     =Axy6
  18. Originator: austern@isolde.mti.sgi.com
  19.  
  20. On 29 Mar 1996 09:07:43 PST, davidb@datalytics.com (David Bradley)
  21. wrote:
  22.  
  23. >On the surface this sounds good.  The obvious problem is the issue of
  24. >access.  You may want the a private set and public get.
  25.  
  26. >Another problem is you are unable to perform any validation within the
  27. >set function.
  28.  
  29. The property class was designed to caputure the "get/set" pattern for
  30. simple value types that need no validation.  In his article, the
  31. author explains that the idea originated with Delphi properties.  It
  32. posted this class in response to a discussion regarding adding
  33. extensions to C++ to allow read/write access to member variables.
  34. Basically, I wanted to point out that using a simple template class
  35. you could accomplish the same thing the proposed extensions would
  36. accomplish.  If you only wanted a public get, you could take the
  37. property template and create a new version called read_only_property
  38. in which the set member not provided.  I think that most of us would
  39. agree that public data members are a bad thing and that acessing them
  40. through function calls allows us to later change how the data members
  41. are represented with out affecting client code.
  42.  
  43. >Lastly the naming of the data member/accessors breaks most common
  44. >styles.  Usually the member functions are distingiushed in some manner
  45. >from the data members.
  46.  
  47. If you mean not explicitly naming the get/set functions with get/set
  48. tacked on the beginning of the name then yes, I agree that the
  49. property template breaks with common style.  Personally, I never use
  50. get/set prefixes in any of the code that I write.  When I do have
  51. members that perform get/set operations I overload member function
  52. acessors with names like those used by the property class.  Client
  53. code should never rely on any internal class implementation details;
  54. only interfaces to the services provided by the class.
  55.  
  56.  
  57. Jason
  58. ---
  59. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  60.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  61.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  62.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  63.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  64. ]
  65.